#ifndef RECON_H
#define RECON_H

#define CERES_FOUND true
#include <QCoreApplication>
#include "opencv2/opencv.hpp"
#include "opencv2/sfm.hpp"
#include "opencv2/xfeatures2d.hpp"

#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <map>
#include <fstream>

#include <boost/filesystem.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/connected_components.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/graphviz.hpp>

using namespace std;
using namespace cv;
namespace fs = boost::filesystem;

class recon
{
public:
    recon();
    map<string, Mat> findImagesInDiretcory(string dirPath);
    void extractFeatures(map<string, Mat> images);

    vector<DMatch> matchWithRatioTest(const DescriptorMatcher& matcher,
                                      Mat desc1, Mat desc2,
                                      float MATCH_RATIO_THRESHOLD = 0.6);
    void matchFeatures();
    void buildTracks();
    bool reconstructFromTracks();
    void visualize3D();

    map<string, int> imageIDs;
    map<string, Mat> images;
    vector<string> imagesNames;
    map<string, vector<KeyPoint>> keypoints;
    map<string, Mat> descriptors;
    map<pair<string, string>, vector<DMatch>> matches;
    vector<Mat> tracks;
    bool saveDebugVisualizations = true;

    vector<Mat> Rs, Ts;
    vector<Mat> points3d;
    vector<Vec3f> pointCloud;
    vector<Vec3b> pointCloudColor;
    Matx33f K_;
};

#endif // RECON_H
